<?php
class WorksCommentAction extends Action{
	private $wc;
	public function __construct()
	{
		parent::__construct();
		$this->wc = new WorksCommentModel();
	}
	
	protected function init()
	{

	}
	public function display()
	{
		
	}
	public function doAddWC()
	{
		$signatures = array(
			'wc_work_id' => array('name' => '作品ID', 'required' => true, 'type' => 'int'),
			'wc_author_id' => array('name' => '作者ID', 'required' => true, 'type' => 'int'),
			'wc_text' => array('name' => '评论内容', 'required' => true, 'type' => 'string')
			);

		$this->checkVars($this->post, $signatures);

		$this->wc->create();

		if($this->wc->add()){
			$msg = "添加评论成功";
			$work = new WorkModel();
			$work->addCondition('work_id', '=', $this->wc->wc_work_id, "");
			$work->findOne();
			$work->reply_number++;
			$work->addCondition('work_id', '=', $this->wc->wc_work_id, "");
			$work->update();
		}else{
			$msg = "添加评论失败!";
		}
		$this->showMessage($msg);
	}
	public function doView()
	{
		if($this->session->getAttr("uid") == null){
			$this->forward("Index");
		}

		$this->smarty->display("profile.tpl");
	}
};
?>

